package com.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pojo.SysLog;
import com.service.SysLogService;
import com.vo.DataVO;
import com.vo.SysLogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.security.RolesAllowed;

/**
 * @author mornd
 * @date 2020/11/28 - 13:11
 */
@RestController
@RequestMapping("/sysLog")
@RolesAllowed({"ROLE_ADMIN", "ROLE_SUPERADMIN"}) //JSR250权限注解 或者@Secured注解
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    /**
     * 查询系统日志列表
     *
     * @param sysLogVo
     * @return
     */
    @RequestMapping("/list")
    public String findSysLogList(SysLogVo sysLogVo) {
        PageHelper.startPage(sysLogVo.getPage(), sysLogVo.getLimit());
        PageInfo<SysLog> pageInfo = new PageInfo<SysLog>(sysLogService.findSysLogList(sysLogVo));
        return JSON.toJSONString(new DataVO<SysLog>(pageInfo.getTotal(), pageInfo.getList()));
    }
}
